package xyz.scootaloo.oj.leetcode;

/**
 * 设计
 * @author flutterdash@qq.com
 * @since 2021/3/27 15:48
 */
public class P1603 {

    private static class ParkingSystem {
        final int[] bigCap = {0, 0};
        final int[] mediumCap = {0, 0};
        final int[] smallCap = {0, 0};

        public ParkingSystem(int big, int medium, int small) {
            bigCap[0] = big;
            mediumCap[0] = medium;
            smallCap[0] = small;
        }

        public boolean addCar(int carType) {
            switch (carType) {
                // da
                case 1: {
                    if (bigCap[0] - bigCap[1] >= 1) {
                        bigCap[1]++;
                        return true;
                    } else {
                        return false;
                    }
                }
                // 中
                case 2: {
                    if (mediumCap[0] - mediumCap[1] >= 1) {
                        mediumCap[1]++;
                        return true;
                    } else {
                        return false;
                    }
                }
                default: {
                    if (smallCap[0] - smallCap[1] >= 1) {
                        smallCap[1]++;
                        return true;
                    } else {
                        return false;
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
        System.out.println(parkingSystem.addCar(1));
        System.out.println(parkingSystem.addCar(2));
        System.out.println(parkingSystem.addCar(3));
        System.out.println(parkingSystem.addCar(1));
    }

}
